package com.easy.base.api.model.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Entity(name = "menu_item")
@Proxy(lazy = false)
@DynamicInsert
@DynamicUpdate
@ApiModel("MenuDataItem")
public class MenuItemEntity extends BaseEntity {
    @ApiModelProperty("路由")
    private String path;

    @ApiModelProperty("路由名称")
    private String name;

    @ApiModelProperty("路由图标")
    private String icon;

    @Column(name = "parent_id")
    @ApiModelProperty("父级ID")
    private String parentId;

    @ApiModelProperty("排位")
    private int sort;

    @ApiModelProperty("权限")
    private String access;

    @OneToMany(targetEntity = MenuItemEntity.class)
    @JoinColumn(name = "id", referencedColumnName = "parent_id")
    @ApiModelProperty("子路由")
    private List<MenuItemEntity> routes;
}
